package com.milk.service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.redis.core.StringRedisTemplate;

import com.milk.web.ApplicationContextUtils;


public class DemoServiceMock implements DemoService{
	
	private Logger log = LoggerFactory.getLogger(this.getClass());
	
	
	private StringRedisTemplate stringRedisTemplate;
	
	public DemoServiceMock(){
		stringRedisTemplate = (StringRedisTemplate)ApplicationContextUtils.getBean("stringRedisTemplate");
	}

	public String sayHello() {
		// TODO Auto-generated method stub
		
		String v = stringRedisTemplate.opsForValue().getAndSet("hello", "失败");
		
		if(v!=null&&"成功".equals(v)){
			log.error("需要执行回滚操作");
		}
		
		return "远程服务请求失败";
	}


}
